#include <iostream>
#include <math.h>
using namespace std;


int main(){
	int n,K;
	cin>>n>>K;
	int arr[n];
	int index = 0;
	for(int i = 0;i < n;i++){
		cin>>arr[i];
	}
	for(int i = 0;i < n;i++){
		for(int j = i+1; j < n ;j++){
			int x = 0;
			int y = 0;
			int ans = arr[i];
			int res = arr[j];
			while(ans>0){
				ans /= 10;
				x++;
			}
			while(res>0){
				res /= 10;
				y++;
			}
			int new1 = arr[i] *pow(10,y)+arr[j];
			int new2 = arr[j] *pow(10,x)+arr[i];
			if(new1%K==0){
				index++;
			}
			if(new2%K==0){
				index++;
			}
		}
	}
	cout<<endl;
	cout<<index<<endl;
	
	system("pause");
	return 0;
}
